package com.corot.codoc.service.impl;

import com.corot.codoc.bean.EBook;
import com.corot.codoc.dao.EBookDao;
import com.corot.codoc.service.EBookService;
import com.corot.core.model.entity.Page;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.lang.reflect.InvocationTargetException;

/**
 * 类的描述
 *
 * @author leesir
 */
@Service
@Transactional
public class EBookServiceImpl implements EBookService {

    private static final Logger LOGGER = LoggerFactory.getLogger(EBookService.class);

    @Autowired
    private EBookDao eBookDao;

    @Override
    public void createEBook(String name) throws InvocationTargetException, IllegalAccessException {
        EBook eBook = new EBook(name);
        eBookDao.save(eBook);
    }

    @Override
    public void updateEBook(EBook eBook) throws InvocationTargetException, IllegalAccessException {
        eBookDao.save(eBook);
    }

    @Override
    public void deleteEBook(Integer id) {
        eBookDao.deleteById(id);
    }

    @Override
    public Page<EBook> getEBooks(Page<EBook> page) {
        return eBookDao.find(page);
    }
}
